<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Admin/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<User>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <% Role r = ((Role)ViewData["Role"]); %>
    
    <fieldset>
        <legend><%= Html.ThemeImage("roles.png") %> Role Details: <%= r.Name %></legend>
        <% using(Html.BeginForm("EditRole", "Roles", FormMethod.Post)){ %>
        <fieldset>
            <legend>Edit Role</legend>
            <dl class="form">
                <dt>Name</dt>
                <dd>
                    <%= Html.TextBox("Name", r.Name) %>
                    <%= Html.ValidationMessage("Name") %>
                </dd>
                    
                <dt>Associate a rank</dt>
                <dd>
                    <%= Html.DropDownList("RankID", "(No Rank)")%>
                </dd>        
                
                <dt>Is a group</dt>
                <dd>
                    <%= Html.CheckBox("IsGroup", r.IsGroup) %>
                </dd>

                <dt>Special Permission</dt>
                <dd><%= Html.DropDownList("SpecialPermissions") %></dd>
                                    
                <dt>&nbsp;</dt>
                <dd>
                    <%= Html.Hidden("RoleID", r.RoleID) %>
                    <%= Html.SubmitButton("SaveChanges", "Save Changes") %>
                </dd>
            </dl>
        </fieldset>
        <% } %>
        <% using(Html.BeginForm("AddUserToRole", "Roles")){ %>
        <fieldset>
            <legend>Add User to Role</legend>
            
            <dl class="form">
                <dt>Username</dt>
                <dd>
                    <%= Html.TextBox("Username") %>

                </dd>
                
                <dt>&nbsp;</dt>
                <dd>
                    <%= Html.Hidden("RoleID", r.RoleID) %>
                    <input type="submit" value="Add User" />
                </dd>
            </dl>
        </fieldset>
        <% } %>
        

        <dl class="details">
            <dt>Users in Role: <%= r.Name %> (<%= Model.Count() %>)</dt>

            <% foreach(User u in Model){ %>
        
            <dd>
                <%= Html.AdminDeleteImageLink(Url.Action("RemoveFromRole", new { UserID = u.UserID, RoleID = r.RoleID }), Url.Action("RoleDetails", "Roles", new { RoleID = r.RoleID }), "Remove from role") %>
                |
                <%= Html.ActionLink(u.Username, "UserDetails", "Users", new { UserID = u.UserID }, null) %>
            </dd>
        
            <%} %>
        
            <% if(Model.Count() == 0){ %>
            <dd>No users in role</dd>
            <%} %>            
        </dl>

    </fieldset>

    


</asp:Content>
